package com.WKH;

import com.GZX.Account;
import com.GZX.Dormitory;
import com.publicClass.User;
import com.util.Vessel;
import com.util.file.Student;
import com.util.file.Teacher;

import java.util.List;
import java.util.Scanner;

import static com.GZX.idCard.manageCard;
import static com.GZX.idCard.studentCard;
import static com.util.Vessel.idCards;
import static com.util.Vessel.tmUser;

public class InfoManage {
    //学生界面
    public static void stuOperation(long id){
        Scanner scanner = new Scanner(System.in);
        boolean isFlag = true;
        do {
            System.out.println("请选择您需要的操作");
            System.out.println("1.查看个人信息");
            System.out.println("2.修改密码");
            System.out.println("3.宿舍详情");
            System.out.println("4.我的校园卡");
            System.out.println("5.退出当前页面");
            int i = scanner.nextInt();
            switch (i) {
                case 1:
                    Student.viewStudentInfo(id);
                    break;
                case 2:
                    Student.updateSpassword(id);
                    break;
                case 3:
                    boolean isFlag1 = true;
                    do {
                        System.out.println("宿舍详情页面");
                        System.out.println("1.查看我的宿舍");
                        System.out.println("2.查看宿舍公告");
                        System.out.println("3.宿舍报修申请");
                        System.out.println("4.退出宿舍详情页");

                        int i1 = scanner.nextInt();
                        switch (i1){
                            case 1:
                                Dormitory.myDormitory(id);
                                break;
                            case 2:
                                Dormitory.check();
                                break;
                            case 3:
                                Dormitory.apply(id);
                                break;
                            case 4:
                                studentCard();
                                break;
                        }
                    }while (isFlag1);
                    break;
                case 4:
                    studentCard();
                    break;
                case 5:
                    isFlag = false;
                    break;
            }
        }while (isFlag);
    }

    //教师界面
    public static void teaOperation(long id){
        Scanner scanner = new Scanner(System.in);
        boolean isFlag = true;
        do {
            System.out.println("请选择您需要的操作");
            System.out.println("1.查看个人信息");
            System.out.println("2.修改密码");
            System.out.println("3.学生宿舍管理");
            System.out.println("3.退出当前页面");
            int i = scanner.nextInt();
            switch (i){
                case 1:
                    Teacher.viewTeacherInfo(id);
                    break;
                case 2:
                    Teacher.updateTpassword(id);
                    break;
                case 3:
                    boolean isFlag1 = true;
                    do {
                        System.out.println("学生宿舍管理页面");
                        System.out.println("1.查看学生宿舍列表");
                        System.out.println("2.查找学生宿舍信息");
                        System.out.println("3.查询宿舍成员");
                        System.out.println("4.退出当前页面");
                        int i1 = scanner.nextInt();
                        switch (i1){
                            case 1:
                                Dormitory.printList();
                                break;
                            case 2:
                                Dormitory.printList();
                                Dormitory.infoDormitory();
                                break;
                            case 3:
                                Dormitory.printList();
                                Dormitory.member();
                                break;
                            case 4:
                                isFlag1 = false;
                                break;
                        }
                    }while (isFlag1);
                    break;
                case 4:
                    isFlag = false;
                    break;
            }
        }while(isFlag);
    }

    //管理界面
    public static void adminOperation(long id){
        Scanner scanner = new Scanner(System.in);
        boolean isFlag =true;
        do {
            System.out.println("请选择您需要的操作");
            System.out.println("1.添加用户信息");
            System.out.println("2.删除用户信息");
            System.out.println("3.修改用户信息");
            System.out.println("4.查询用户信息");
            System.out.println("5.查看教师/管理员注册申请");
            System.out.println("6.学生宿舍管理");
            System.out.println("7.校园卡管理");
            System.out.println("8.退出当前页面");
            int i = scanner.nextInt();
            switch (i) {
                case 1:
                    boolean b = User.addUser();
                    if (!b) {
                        for (User user : Vessel.users) {
                            System.out.println(user.toString());
                        }
                    }
                    break;
                case 2:
                    boolean b1 = User.delUser();
                    if (!b1) {
                        for (User user : Vessel.users) {
                            System.out.println(user.toString());
                        }
                    }
                    break;
                case 3:
                    boolean b2 = User.updateUser();
                    if (!b2) {
                        for (User user : Vessel.users) {
                            System.out.println(user.toString());
                        }
                    }
                    break;
                case 4:
                    System.out.println("请选择您要查询的方法");
                    System.out.println("1.id查询");
                    System.out.println("2.身份查询");
                    int i1 = scanner.nextInt();
                    switch (i1) {
                        case 1:
                            User.findUser();
                            break;
                        case 2:
                            User.findRole();
                            break;
                    }
                    break;
                case 5:
                    Account.check(tmUser);
                    break;
                case 6:
                    boolean isFlag1 = true;
                    do {
                        System.out.println("学生宿舍管理页面");
                        System.out.println("请选择您的操作");
                        System.out.println("1.查看全部宿舍");
                        System.out.println("2.查找宿舍信息");
                        System.out.println("3.查看宿舍成员");
                        System.out.println("4.发布宿舍公告");
                        System.out.println("5.查看宿舍公告");
                        System.out.println("6.宿舍维修审核");
                        System.out.println("7.宿舍维修进度");
                        System.out.println("8.退出宿舍管理页面");

                        int i2 = scanner.nextInt();
                        switch (i2){
                            case 1:
                                Dormitory.printList();
                                break;
                            case 2:
                                Dormitory.printList();
                                Dormitory.infoDormitory();
                                break;
                            case 3:
                                Dormitory.printList();
                                Dormitory.member();
                                break;
                            case 4:
                                Dormitory.publish();
                                break;
                            case 5:
                                Dormitory.check();
                                break;
                            case 6:
                                Dormitory.approve();
                                break;
                            case 7:
                                Dormitory.service();
                                break;
                            case 8:
                                isFlag1 = false;
                                break;
                        }
                        System.out.println("是否继续操作：1：是   2：退出");
                        int input = scanner.nextInt();
                        isFlag1 = (input == 1);
                    }while (isFlag1);
                    break;
                case 7:
                    manageCard();
                    break;
                case 8:
                    isFlag = false;
                    break;
            }
        }while (isFlag);
    }
}
